#include<iostream>


bool isLeapYear(int year) {
    return (year % 4 == 0 && year % 100 != 0) || (year % 100 == 0 && year % 400 == 0);
}

int dayOfWeek(int year, int month, int day) {
    int dayOfMonth[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    int dayOfYear = 365;
    int sum = 0;
    for (int i = 1900; i < year; ++i) {
        if (isLeapYear(i)) {
            sum += (dayOfYear + 1) % 7;
        } else {
            sum += dayOfYear % 7;
        }
    }
    for (int i = 1; i < month; ++i) {
        sum += dayOfMonth[i - 1] % 7;
    }
    if (isLeapYear(year) && month > 2) {
        sum += 1;
    }
    return (sum + day) % 7 ;
}

int dayOfWeek2(int year, int month, int day) {
    if (month == 1 || month == 2) {
            year--;
            month += 12;
    }
    int c = year / 100;
    int y = year - c * 100;
    int week = y + y / 4 + c / 4 - 2 * c + 26 * (month + 1) / 10 + day - 1;
    return (week + 7) % 7;
}

int main() {
    // std::cout << (dayOfWeek(1900, 1, 1)) % 7 << std::endl;//星期一
    // std::cout << (dayOfWeek(2022, 2, 9)) % 7 << std::endl;//星期三
    // std::cout << (dayOfWeek(2020, 12, 14)) % 7 << std::endl;//星期一
    // std::cout << (dayOfWeek(2019, 6, 18)) % 7 << std::endl;//星期二
    // std::cout << (dayOfWeek(2022, 2, 27)) % 7 << std::endl;//星期日
    // std::cout << (dayOfWeek(2018, 6, 14)) % 7 << std::endl;//星期四
    // std::cout << (dayOfWeek(2018, 6, 14)) % 7 << std::endl;//星期四
    // std::cout << (dayOfWeek(2013, 1, 11)) % 7 << std::endl;//星期五
    // std::cout << (dayOfWeek(1900, 1, 2)) % 7 << std::endl;//星期二

    std::cout << (dayOfWeek(1900, 1, 1) == dayOfWeek2(1900, 1, 1)) << std::endl;
    std::cout << (dayOfWeek(2022, 2, 9) == dayOfWeek2(2022, 2, 9)) << std::endl;
    std::cout << (dayOfWeek(2020, 12, 14) == dayOfWeek2(2020, 12, 14)) << std::endl;
    std::cout << (dayOfWeek(2019, 6, 18) == dayOfWeek2(2019, 6, 18)) << std::endl;
    std::cout << (dayOfWeek(2022, 2, 27) == dayOfWeek2(2022, 2, 27)) << std::endl;
    std::cout << (dayOfWeek(2018, 6, 14) == dayOfWeek2(2018, 6, 14)) << std::endl;
    std::cout << (dayOfWeek(2018, 6, 14) == dayOfWeek2(2018, 6, 14)) << std::endl;
    std::cout << (dayOfWeek(2013, 1, 11) == dayOfWeek2(2013, 1, 11)) << std::endl;
    std::cout << (dayOfWeek(1900, 1, 2) == dayOfWeek2(1900, 1, 2)) << std::endl;


    return 0;
}